/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package eeep.controle;

import eeep.dao.EnderecoDAO;
import eeep.entidades.Endereco;
import eeep.excecoes.ENDJCException;
import eeep.excecoes.ENDNEException;

/**
 *
 * @author Junior
 */
public class EnderecoControle {
    EnderecoDAO dao = new EnderecoDAO();
    public Endereco buscaEndereco(Endereco endereco) throws ENDNEException{
        if(dao.getEndereco(endereco)==null){
            throw new ENDNEException();
        }else{
            return endereco;
        }
    }
    
    public void salvarEndereco(Endereco endereco) throws ENDJCException{
        try{
            this.buscaEndereco(endereco);
            throw new ENDJCException();
        }catch(ENDNEException e){
            dao.salvarEndereco(endereco);
        }
    }
    
    
}
